<?php
namespace Admin\Controller;

use Common\Controller\AdminbaseController;

class InfoController extends AdminbaseController
{

    protected $info_model;


    public function _initialize()
    {
        parent::_initialize();
        $this->info_model = D("Common/Info");
    }

//获取信息
    public function index()
    {
//        $sql = " SELECT * FROM cmf_info";
        $infos = $this->info_model->find();

//        exit($infos);

        $this->assign("infos", $infos);
        $this->display();

    }

    //编辑提交
    public function edit_post()
    {
        $_POST['update_time'] = date("Y-m-d H:i:s", time());
        if (IS_POST) {
            if ($this->info_model->create() !== false) {
                if ($this->info_model->save() !== false) {
                    $this->success("保存成功！", U("Info/index"));
                } else {
                    $this->error("保存失败！");
                }
            } else {
                $this->error($this->info_model->getError());
            }
        }
    }


}